package org.wcms.surrounded.modules;

import org.wcms.surrounded.model.KeyValuePair;
import org.wcms.surrounded.model.Record;
import org.wcms.surrounded.model.User;
import org.wcms.surrounded.persistence.ObjectifyProvider;
import org.wcms.surrounded.persistence.SurroundedRegistry;

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;

public class SurroundedPersistenceModule extends AbstractModule {

    private final Class<?>[] entities = {
        User.class,
        Record.class,
        KeyValuePair.class
    };
    
    @Override
    protected void configure() {

        bind(ObjectifyFactory.class).asEagerSingleton();

        bind(Class[].class).annotatedWith(Names.named("entities")).toInstance(entities);
        bind(SurroundedRegistry.class).asEagerSingleton();
        
        bind(Objectify.class).toProvider(ObjectifyProvider.class);
        
    }

}
